using System;
using System.Data;
using System.Data.Linq;
using System.Linq;
using Magiq.Support.Database;

namespace Magiq.Sql {
    public class SqlDatabaseAdapter : IDatabaseAdapter {
        private readonly DataContext dataContext;
        public SqlDatabaseAdapter(DataContext dataContext) {
            this.dataContext = dataContext;
        }

        public IDbCommand GetCommand(IQueryable queryable) {
            return dataContext.GetCommand(queryable);
        }

        public ITypeMapping GetMappingOf(Type type) {
            return new SqlTypeMapping(dataContext.Mapping.GetMetaType(type));
        }
    }
}